package com.hhsjdesign.test;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.DisplayCutout;
import android.view.View;
import android.view.WindowInsets;

import androidx.appcompat.app.AppCompatActivity;

import com.hhsjdesign.headerpullrefresh.R;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);

        setContentView(R.layout.activity_splash);

        findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                startActivity(new Intent(SplashActivity.this, MainActivity.class));
            }
        });

    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {

            WindowInsets rootWindowInsets = getWindow().getDecorView().getRootWindowInsets();
            if (null != rootWindowInsets) {

                DisplayCutout displayCutout = rootWindowInsets.getDisplayCutout();

                if (displayCutout != null) {
                    int safeInsetLeft = displayCutout.getSafeInsetLeft();
                    int safeInsetTop = displayCutout.getSafeInsetTop();
                    int safeInsetRight = displayCutout.getSafeInsetRight();
                    int safeInsetBottom = displayCutout.getSafeInsetBottom();

                    Log.e("HHSJHHSJ", "left = " + safeInsetLeft + " top = " + safeInsetTop + " right = " + safeInsetRight + " bottom = " + safeInsetBottom);

                }

            }

            Class ftF = null;
            try {
                ftF = Class.forName("android.util.FtFeature");
                Method method = ftF.getDeclaredMethod("isFeatureSupport", int.class);
                boolean a = (boolean) method.invoke(null, 0x00000020);

                Log.e("HHSJHHSJ", a ? "有凹槽" : "无凹槽");
                boolean b = (boolean) method.invoke(null, 0x00000008);
                Log.e("HHSJHHSJ", b ? "有圆角" : "无圆角");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }

        }

    }


}
